from PyQt4.QtGui import * 
from PyQt4.QtCore import * 
from animationpanel import *

class PreviewWindow(QWidget):
    def __init__(self, sprite, parent=None):
        QWidget.__init__(self, parent)
        self.resize(150, 150)
        self.vbox = QVBoxLayout()
        
        self.windows = []
        self.animation = AnimationPanel(sprite)
        self.slider = QSlider()
        self.slider.setOrientation(Qt.Horizontal)
        self.hbox = QHBoxLayout()
        self.hbox.addWidget(QLabel("Speed"))
        self.playpause = QPushButton("|> / ||")
        self.playpause.setCheckable(True)
        self.connect(self.playpause, SIGNAL('clicked()'), self.toggle_playpause)

        self.hbox_animation = QHBoxLayout()
        self.hbox_animation.addWidget(self.animation)
        
        self.vbox.addLayout(self.hbox_animation)
        #self.vbox.addWidget(self.slider)
        #self.vbox.addLayout(self.hbox)
        self.vbox.addWidget(self.playpause)
        self.vbox.setSizeConstraint(QLayout.SetMinAndMaxSize)
        self.vbox.insertStretch(1)
        
        
        self.setLayout(self.vbox)

    def toggle_playpause(self):
        self.animation.set_playpause(self.playpause.isChecked())
